package com.example.transaction.Task;
import com.example.transaction.sys.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;


@Component
public class OrderExpirationTask {

    @Autowired
    private IOrderService orderService;

    @Scheduled(fixedRate = 1000) // 每秒检查一次
    public void checkAndPublishExpiredOrders() {
        LocalDateTime now = LocalDateTime.now();
        orderService.findAndPublishExpiredOrders(now);
    }
}

